package com.asset.user.form;

import com.asset.user.dao.entity.UserEntity;

/**
 * @author luoyongzhi
 */
public class UserForm {

    /**
     * 用户id
     */
    private Long id;

    /**
     * 用户昵称
     */
    private String name;

    /**
     * 登录密码
     */
    private String password;

    /**
     * 联系方式
     */
    private String telephone;

    /**
     * 性别
     */
    private Integer gender;

    /**
     * 创建时间
     */
    private String createTime;

    /**
     * 修改时间
     */
    private String modifyTime;

    /**
     * 删除标识
     */
    private Integer deleteFlag;



    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public Integer getGender() {
        return gender;
    }

    public void setGender(Integer gender) {
        this.gender = gender;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(String modifyTime) {
        this.modifyTime = modifyTime;
    }

    public Integer getDeleteFlag() {
        return deleteFlag;
    }

    public void setDeleteFlag(Integer deleteFlag) {
        this.deleteFlag = deleteFlag;
    }

    public static UserEntity convert2Entity(UserForm userForm) {
        if (userForm == null) {
            return null;
        }
        UserEntity entity = new UserEntity();
        if (userForm.getId() != null) {
            entity.setId(userForm.getId());
        }
        if (userForm.getName() != null) {
            entity.setName(userForm.getName());
        }
        if (userForm.getPassword() != null) {
            entity.setPassword(userForm.getPassword());
        }
        if (userForm.getTelephone() != null) {
            entity.setTelephone(userForm.getTelephone());
        }
        if (userForm.getGender() != null) {
            entity.setGender(userForm.getGender());
        }
        return entity;
    }

    public static UserForm convert2Form(UserEntity entity) {
        if (entity == null) {
            return null;
        }
        UserForm userForm = new UserForm();
        if (entity.getId() != null) {
            userForm.setId(entity.getId());
        }
        if (entity.getName() != null) {
            userForm.setName(entity.getName());
        }
//        if (entity.getPassword() != null) {
//            userForm.setPassword(entity.getPassword());
//        }
        if (entity.getTelephone() != null) {
            userForm.setTelephone(entity.getTelephone());
        }
        if (entity.getGender() != null) {
            userForm.setGender(entity.getGender());
        }
        return userForm;
    }
}
